﻿/***************************************************************
* File    : AfrSensor.cs
* Author  : Matthew Clifton
*
* Description:
*   Abscraction of Sensor class, ultimately repsonsible for handling the Air Fuel Ratio sensors.
*
* History :
***************************************************************/

using System;

namespace RLGDashboard
{
    public class AFRSensor : Sensor
    {
        /***************************************************************
        * Public                 convert
        *
        * sensor routine which is responsible for taking the raw unconverted values, and performing the calculations needed
        * to obtain the actual sensor value
        *
        * Inputs
        * UInt16[] values: Array of size 4 containing all raw AFR values (gauge only has 1 AFR sensor, room for 3 more in future)
        * 
        * Outputs
        * object[] convertedValues: Array of objects (allows for integers or floating points) that has the calculated sensor values
        * 
        * History:
        ****************************************************************/
        public override object[] convert(UInt16[] inValues)
        {
            object[] convertedValues = new object[4];

            //Calculate AFR Sensor values (SEE Redlinge Gauges ICD)
            convertedValues[0] = ((double)(inValues[0]) / 100.0);

            //Get error code.
            UInt16 errorCode = (UInt16)inValues[1];

            //Check error code
            if (errorCode != 0xFF00)
            {
                //Indicates error.
                convertedValues[0] = "ERR";
            }

            return convertedValues;
        }

        /***************************************************************
        * Public                 getValues
        *
        * Sensor routine responsible for getting the 
        *
        * Inputs
        * None
        * 
        * Outputs
        * string[] values: Array of strings containing sensor values and units.
        * 
        * History:
        ****************************************************************/
        /*   public override string[] getValues()
           {
               string[] values = new string[4];

               if (currentSensorValues[0] != "ERR")
               {
                   values[0] = currentSensorValues[0].ToString() + " %02";
               }
               else
               {
                   values[0] = (string)currentSensorValues[0];
               }

               updated = false;
               return values;
           }*/
    }
}